package mango.orm;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.List;

import mango.orm.entity.Entity;



@SuppressWarnings("rawtypes")
public interface Dao {
    public static final int TYPE_QUERY = 1;
    public static final int TYPE_UPDATE = 2;
    public static final int TYPE_CREATE = 3;
    public static final int TYPE_DELETE = 4;
    public static final int TYPE_OTHER = 99;

    public Dao setType(int type);

    public int getType();

    public Dao setStart(int firstResult);

    public Dao setLimit(int fatchSize);

    public Dao setResultType(Class<? extends Entity> clazz);

    public Class getResultType();

    public Dao setParameter(Object... val);

    public Dao setParamByName(String name, Object val);
    
    public Dao setParameter(Entity bean);
    
    public Dao setSubSql(int index, String subsql);
    
    public Dao setSubSql(String... subsql);

    /**
     * select
     * @return
     */
    public ResultSet executeQuery() throws SQLException;

    public Iterator<Entity> queryIterator();
    
    public boolean hasNextPage();
    
    public Iterator<Entity> nextPage();
    
    public Iterator<String> iterString();

    public List<Entity> listQuery();

    public List<String> listQueryString();

    public Entity uniqueResult();

    public String getStringValue();

    public int getIntValue();

    public double getDoubleValue();
    
    public long getLongValue();

    public int getTotalCount();

    /**
     * update
     * 
     * @param batcher
     */
    public int executeUpdate();

    public boolean execute();

    public void executeBatch();
    
    public void close();
}
